--[[
  author: blog.163.com/mr_zyf/
]]
local _cclogs={}
-- cclog信息记录
function cclog(...)
   local n=#_cclogs
   _cclogs[n+1]=tostring(n+1)..":<"..os.date()..">:"..string.format(...)
end
--cclog保存记录
function cclogSave()
   local n=#_cclogs
   --log文件保存的位置，是针对android平台
   local f=io.open("/mnt/sdcard/cocos2dx_log.txt","w+")
   for i=1,n do
      f:write(_cclogs[i].."\n")
   end
   f:close() 
end
-- for CCLuaEngine traceback
function __G__TRACKBACK__(msg)
    cclog("----------------------------------------")
    cclog("LUA ERROR: " .. tostring(msg) .. "\n")
    cclog(debug.traceback())
    cclog("----------------------------------------")
    cclogSave()
end
local function main()
    cclog("main begin")
    -- avoid memory leak
    collectgarbage("setpause", 100)
    collectgarbage("setstepmul", 5000)

    local sceneGame = CCScene:create()
    local GameLayer=require("gameLayer")
    local gameLayer=GameLayer:lCreate()
    sceneGame:addChild(gameLayer)
    cclog("sceneGame:addChild")
    CCDirector:sharedDirector():runWithScene(sceneGame)
    cclog("main end")
end

xpcall(main, __G__TRACKBACK__)
